<?php
namespace Common\Model;
use Think\Model;
use Home\Service\WechatService;
use Home\Service\ClockTimeService;
// +----------------------------------------------------------------------
// | Date:2017年2月9日
// +----------------------------------------------------------------------
// | Author: EK_熊<1439527494@qq.com>
// +----------------------------------------------------------------------
// | Description: 考勤数据流水记录模型
// +----------------------------------------------------------------------
class AttendanceModel extends Model{
    
    
    /**
     * 考勤数据入库处理
     * @param unknown $data
     * 把合并处理后的数据再返回出来
     * date:2017年2月9日
     * author: EK_熊
     */
    public function write_to_db($data){
        $isExist = $this->where(['sn'=>$data['sn'],'recept_time'=>$data['time']])->find();
        if ($isExist) return null;
        $timeInfo = getdate(strtotime($data['time']));
        $data['date']   = $data['time'];
        $data['recept_time'] = $data['time'];
        $data['year']   = $timeInfo['year'];
        $data['month']  = $timeInfo['mon'];
        $data['day']    = $timeInfo['mday'];
        $data['hour']   = $timeInfo['hours'];
        $data['minute'] = $timeInfo['minutes'];
        $data['second'] = $timeInfo['seconds'];
        $data['created_time'] = CURRENT_TIME;
        $add = $this->add($data);
        return $add;
    }
    
    public function isExist($devid){
        $where['dev_id'] = $devid;
        $ret = $this->where($where)->find();
        return $ret;
    }


    
    
    
}